package com.roy.comet.parse;

import com.alibaba.druid.sql.parser.Lexer;
import com.alibaba.druid.sql.parser.Token;

/**
 * Created by mc on 18/4/13.
 */
public class InsertSqlParseStrategy implements SqlParseStrategy {

    @Override
    public CometSqlBean getCometSqlBean(CometSqlBean cometSqlBean, Lexer lexer, String sql, String dbName, String tableName) {
        lexer.nextToken();
        Token tok = lexer.token();
        if (tok.name.equals("INTO")) {
            lexer.nextToken();
            tableName = lexer.token().name;
            cometSqlBean.setDbName(dbName);
            cometSqlBean.setSqlType(CometSqlBean.SqlType.INSERT);
            cometSqlBean.setTableName(tableName);
            cometSqlBean.setSql(sql);
            return cometSqlBean;
        }else {
            getCometSqlBean( cometSqlBean, lexer, sql,  dbName, tableName);
        }

        return cometSqlBean;
    }
}
